@model List<RolesInUserViewModel>

@{ var userId = ViewBag.userId; }

<form method="post">
    <div class="card">
        <div class="card-header">
            <h2>管理用户中的角色</h2>
        </div>
        <div class="card-body">

            @*@foreach (var role in Model)
                {
                    <div class="form-check m-1">
                        <input type="hidden" asp-for="@role.RoleId" />
                        <input type="hidden" asp-for="@role.RoleName" />
                        <input asp-for="@role.IsSelected" class="form-check-input" />
                        <label class="form-check-label" asp-for="@role.IsSelected">
                            @role.RoleName
                        </label>
                    </div>
                }*@

            @for (int i = 0; i < Model.Count; i++)
            {
<div class="form-check m-1">
    <input type="hidden" asp-for="@Model[i].RoleId" />
    <input type="hidden" asp-for="@Model[i].RoleName" />
    <input asp-for="@Model[i].IsSelected" class="form-check-input" />
    <label class="form-check-label" asp-for="@Model[i].IsSelected">
        @Model[i].RoleName
    </label>
</div>}
            <div asp-validation-summary="All" class="text-danger"></div>
        </div>
        <div class="card-footer">
            <input type="submit" value="更新" class="btn btn-primary"
                   style="width:auto" />
            <a asp-action="EditUser" asp-route-id="@userId"
               class="btn btn-primary" style="width:auto">取消</a>
        </div>
    </div>
</form>